<script setup>
import LeadsIndex from './index.vue'
import {useErpUserStore} from "../../../store/modules/usererp.js";
import {ref, computed, onMounted} from "vue"

defineOptions({
  name: 'SzLeadsAllIndex',
})
const componentName = ref(LeadsIndex)

const crm = computed(() => {
  const erpUserStore = useErpUserStore();
  return erpUserStore.crm
})

onMounted(() => {
  // todo whf 没有调用/adminRole/auth接口，所以拿不到crm信息
  if (crm.value && crm.value.leads) {
    componentName.value = LeadsIndex
  }
})

/**
 * 左侧菜单选择
 */
function menuSelect(key, keyPath) {
  componentName.value = {
    leads: LeadsIndex
  }[key]
}
</script>


<template>
  <keep-alive>
    <component :is="componentName" @menu-select="menuSelect"/>
  </keep-alive>
</template>

<style lang="scss" scoped>
</style>
